//
// Created by shen on 2024/12/18.
//

#ifndef AEDITOR_AVFRAMEQUEUE_H
#define AEDITOR_AVFRAMEQUEUE_H
#include "queue"
#include "FFStatus.h"
#include "log.h"
extern "C"{
#include "libavcodec/avcodec.h"
};
typedef struct frameStruct{
    uint8_t *yData;
    uint8_t *uData;
    uint8_t *vData;
    double pts;
}frameStruct;

class AVFrameQueue {
public:
    AVFrameQueue(FFStatus *playerStatus1);
    ~AVFrameQueue();

    int putAvFrame(AVFrame *avFrame);
    int putStructAvFrame(frameStruct *structFrame);
    int getAvFrameByTime(AVFrame *avFrame,double timestamp,AVRational bastTime);
    int getAvFrame(AVFrame *avFrame);
    int getStructAvFrame(frameStruct **structFrame,double timestamp,AVRational bastTime);
    int getQueueSize();
    void clearAvPacket();
    void noticeQueue();

public:
    std::queue<AVFrame *> queuePacket;
    std::queue<frameStruct *> structQueuePacket;
    pthread_cond_t condPacket;
    pthread_mutex_t mutexPacket;
    FFStatus *playerStatus = NULL;





};


#endif //AEDITOR_AVFRAMEQUEUE_H
